<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class HT_Model_administrator_models_partners extends Zend_Db_Table {//ten class fai viet hoa

   protected $_db;

    public function __construct() {
        $this->_name = "partners";
        $this->_db = Zend_Registry::get('dbMain');
        parent::init();
    }
    public function getAll($where){
        $sql = "select * from partners where ".$where;                        
        $retval = $this->_db->fetchAll($sql);        
        return $retval;
    }
    public function findById($id){
        $sql = "select * from partners where id = $id";
        $retval = $this->_db->fetchRow($sql);
        return $retval;
    }
    public function queryInsertEmail(){
        $sql = "INSERT INTO email_user(email) SELECT 
        email FROM user Ur  WHERE active = 1";
        $retval = $this->_db->query($sql);        
        return $retval;
    }
    public function queryInsertEmailAppointment(){
        $sql = "INSERT INTO email_user(email) SELECT 
        DISTINCT email FROM appointment  WHERE type = 3";
        $retval = $this->_db->query($sql);        
        return $retval;
    }
    public function queryInsertEmailService(){
        $sql = "INSERT INTO email_user(email) SELECT 
        DISTINCT UR.email FROM user_service US inner join user UR on US.user_name = UR.user_name  WHERE US.ser_id = 2 or US.ser_id = 3 or US.ser_id = 4";
        $retval = $this->_db->query($sql);        
        return $retval;
    }
}

?>
